package com._520it.crm.service.impl;

import com._520it.crm.domain.DataDictionary;
import com._520it.crm.mapper.DataDictionaryMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IDataDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by sky on 2017/10/12.
 */
@Service
public class DataDictionaryServiceImpl implements IDataDictionaryService {

    @Autowired
    private DataDictionaryMapper dataDictionaryMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return dataDictionaryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(DataDictionary record) {

        return dataDictionaryMapper.insert(record);
    }

    @Override
    public DataDictionary selectByPrimaryKey(Long id) {
        return dataDictionaryMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<DataDictionary> selectAll() {


        return dataDictionaryMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(DataDictionary record) {

        return dataDictionaryMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageResult queryPage(QueryObject qo) {
        Integer total = dataDictionaryMapper.queryForTotal(qo);

        if (total == 0) {
            new PageResult(0, Collections.EMPTY_LIST);
        }

        List<DataDictionary> rows = dataDictionaryMapper.queryForRows(qo);

        return new PageResult(total, rows);


    }
}
